/**
 * 
 */
package com.java.test.system.dto;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author 角色管理
 *
 */
public class RoleInfo implements RowMapper<RoleInfo> {

	// 主鍵id
	private int id;

	// 角色名称
	private String roleName;

	// 创建时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime createTime;

	// 创建人
	private String addPeople;

	// 权限
	private String power;

	private List<MenuInfo> list;

	// 最高权限 系统管理员1  : 其他角色 0
	private int highestAuthority;
	
	
	
	public List<MenuInfo> getList() {
		return list;
	}

	public void setList(List<MenuInfo> list) {
		this.list = list;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public LocalDateTime getCreateTime() {
		return createTime;
	}

	public void setCreateTime(LocalDateTime createTime) {
		this.createTime = createTime;
	}

	public String getAddPeople() {
		return addPeople;
	}

	public void setAddPeople(String addPeople) {
		this.addPeople = addPeople;
	}

	public String getPower() {
		return power;
	}

	public void setPower(String power) {
		this.power = power;
	}
	

	public int getHighestAuthority() {
		return highestAuthority;
	}

	public void setHighestAuthority(int highestAuthority) {
		this.highestAuthority = highestAuthority;
	}

	@Override
	public RoleInfo mapRow(ResultSet rs, int rowNum) throws SQLException {

		RoleInfo info = new RoleInfo();
		info.setId(rs.getInt("id"));
		info.setAddPeople(rs.getString("add_people"));
		info.setCreateTime(rs.getTimestamp("create_time") == null ? null
				: rs.getTimestamp("create_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
		info.setPower(rs.getString("power"));
		info.setRoleName(rs.getString("role_name"));
		
		info.setHighestAuthority(rs.getInt("highestAuthority"));

		return info;
	}

}
